import cgi
import os

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from django.utils import simplejson as json

class JsonTestHdl(webapp.RequestHandler):
  def get(self):
    data = {}
    data['page'] = 1
    data['records'] = 31
    data['items'] = []

    item = {}
    item['id'] = 1
    item['name'] = 'xyz'
    item['phone'] = '123'
    data['items'] += [item]
    
    item = {}
    item['id'] = 2
    item['name'] = 'xyz'
    item['phone'] = '123'
    data['items'] += [item]

    json.dump(data, self.response.out)

#json map test for jgrid query    
class JsonMapHdl(webapp.RequestHandler):
  def get(self):

    data = {}
    data['page'] = 1
    data['total'] = 1
    data['records'] = 13
    data['rows'] = []
    for i in range(1,13) :
      row = {}
      row['id'] = i
      row['invdate'] = '2007-10-6' 
      row['name'] = 'Client ' + str(i)
      row['amount'] = 1000.01
      row['tax'] = 10.01
      row['total'] = 880.01
      row['note'] = 'nothing'
      data['rows'] += [row]
    json.dump(data, self.response.out)

